package com.zhuss.core.company;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.core.company.DetailCompanyBo;
import com.zhuss.bean.bo.core.company.DetailDeptBo;
import com.zhuss.bean.bo.core.company.ListCompanyByTypeBo;
import com.zhuss.bean.bo.core.company.ListDeptByCompanyBo;
import com.zhuss.bean.bo.core.company.SearchCompanyBo;
import com.zhuss.bean.bo.core.company.SearchDeptBo;
import com.zhuss.common.ReadService;
import com.zhuss.core.processor.CompanyRead;
import com.zhuss.core.processor.DeptRead;
import com.zhuss.exception.OceanException;


/**
 * 公司查询service（基本查询）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("companyReadService")
public class CompanyReadService implements ReadService<Object, Object> {
	
	@Autowired
	@Qualifier("companyRead")
	private CompanyRead companyRead;
	
	@Autowired
	@Qualifier("deptRead")
	private DeptRead deptRead;
	
	
	/**
	 * 详情
	 */
	@Override
	public Object detail(Object param) throws OceanException {
		DetailCompanyBo bo = (DetailCompanyBo) param;
		Long companyId = bo.getCompanyId();
		Object vo = companyRead.detail(companyId);
		return vo;
	}
	
	/**
	 * 列表
	 */
	@Override
	public Object list(Object param) {
		SearchCompanyBo bo = (SearchCompanyBo) param;
		Object result = companyRead.list(bo);
		return result;
	}
	
	
	/**
	 * 根据公司查询部门列表
	 */
	public Object listDeptByCompany(Object param) throws OceanException {
		ListDeptByCompanyBo bo = (ListDeptByCompanyBo) param;
		Long companyId = bo.getCompanyId();
		Object vo = deptRead.listSelectByCompany(companyId);
		return vo;
	}
	
	/**
	 * 查询公司列表
	 */
	public Object listAll(Object param) throws OceanException {
		Object vo = companyRead.listSelectByType(null);
		return vo;
	}
	
	/**
	 * 根据公司类型查询公司列表
	 */
	public Object listByType(Object param) throws OceanException {
		ListCompanyByTypeBo bo = (ListCompanyByTypeBo) param;
		Integer type = bo.getType();
		
		Object vo = companyRead.listSelectByType(type);
		return vo;
	}
	
	
	/**
	 * 公司的部门列表
	 */
	public Object deptList(Object param) throws OceanException {
		SearchDeptBo bo = (SearchDeptBo) param;
		Object vo = deptRead.list(bo);
		return vo;
	}
	
	
	/**
	 * 公司的部门列表
	 */
	public Object deptDetail(Object param) throws OceanException {
		DetailDeptBo bo = (DetailDeptBo) param;
		Long deptId = bo.getDeptId();
		Object vo = deptRead.detail(deptId);
		return vo;
	}
	
	
}

